package com.sf.ams.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sf.ams.biz.IExecutorBiz;
import com.sf.ams.entity.Environment;
import com.sf.ams.entity.Response;
import com.sf.ams.entity.SystemInfo;
import com.sf.ams.logging.CommonLogging;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2017年9月27日      Simba.Hua         Create
 * ****************************************************************************
 * </pre>
 * @author Simba.Hua
 */
@Controller
@RequestMapping("/executor")
public class ExecutorController {
	@Autowired
	private IExecutorBiz executorBiz;
	@RequestMapping(value = "/doExecute",method=RequestMethod.POST, consumes="application/json")
	@CommonLogging(content = "执行脚本")
	@ResponseBody
	public Response doExecute(@RequestBody SystemInfo system){
		boolean flag = executorBiz.execute(system);
		if(flag){
			return new Response(Response.STATUS_SUCCESS, "", -1);
		} 
		return new Response(Response.STATUS_FAIL, "", -1);
	}
	@RequestMapping(value = "/refreshStatus",method=RequestMethod.POST, consumes="application/json")
	@ResponseBody
	public List<Environment> refreshStatus(@RequestBody SystemInfo system){
		return executorBiz.refreshStatus(system);
	}
}
